package com.jzg.jcptadmin.adpter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.jzg.jcptadmin.R;
import com.jzg.jcptadmin.data.vo.CarDetails;

import java.util.List;

/**
 * Created by jzg on 2016/2/29.
 */
public class HistoricalPriceAdapter extends BaseAdapter {
    private Context context;
    private List<CarDetails.TaskListData> list;
    private ViewHolder viewHolder;

    public HistoricalPriceAdapter(List<CarDetails.TaskListData> list, Context context) {
        this.list = list;
        this.context = context;

    }
    public HistoricalPriceAdapter( Context context) {
        this.context = context;

    }

    @Override
    public int getCount() {
        return list.size();
    }

    @Override
    public Object getItem(int position) {
        return null;
    }

    @Override
    public long getItemId(int position) {
        return 0;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        if (convertView == null) {
            viewHolder = new ViewHolder();
            convertView = View.inflate(context, R.layout.historical_price_item, null);
            viewHolder.text_appraiser = (TextView) convertView.findViewById(R.id.text_appraiser);
            viewHolder.text_area = (TextView) convertView.findViewById(R.id.text_area);
            viewHolder.text_price = (TextView) convertView.findViewById(R.id.text_price);
            viewHolder.text_time = (TextView) convertView.findViewById(R.id.text_time);
            convertView.setTag(viewHolder);
        }else{
            viewHolder = (ViewHolder) convertView.getTag();
        }
        viewHolder.text_appraiser.setText(list.get(position).getHAppraiserName());
        viewHolder.text_area.setText(list.get(position).getHCityName());
//        viewHolder.text_price.setText("收"+list.get(position).getHPrice()+"\n"+"售435 万");
        if(list.get(position).getC2BPrice().equals("--")){
            viewHolder.text_price.setText(list.get(position).getC2BPrice());
        }else {
            viewHolder.text_price.setText("收" + list.get(position).getC2BPrice() + "\n" + "售" + list.get(position).getB2CPrice());
        }
        viewHolder.text_time.setText(list.get(position).getHDateTime());
        return convertView;
    }




    public class ViewHolder {

        public TextView text_area;//评估地区
        public TextView text_appraiser;//评估师
        public TextView text_price;//评估价格
        public TextView text_time;//评估时间

    }


}
